package com.holly.unit.bpmn.activiti.factory;

import com.holly.unit.bpmn.activiti.pojo.BpmnModelTreeNode;

import java.util.Map;

/**
 * 类描述: BpmnModel 实体转换类
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/4/25 17:44
 */
public class BpmnModelFactory {

    /**
     * 实体转换
     *
     * @param map bpmn模型信息
     * @return BpmnModelTreeNode 树实体对象
     * @author holly
     * @date 2021/1/5 21:07
     */
    public static BpmnModelTreeNode parseBpmnModelTreeNode(Map<String,String> map) {
        BpmnModelTreeNode treeNode = new BpmnModelTreeNode();
        treeNode.setId(map.get("treeId"));
        treeNode.setParentId(map.get("treePid"));
        treeNode.setTitle(map.get("treeName"));
        treeNode.setType(elemTypeConver(map.get("type")));
        treeNode.setModelId(map.get("modelId"));
        return treeNode;
    }

    private static String elemTypeConver(String oldType){
        String newType = "";
        switch (oldType) {
            case "1" : newType = "0"; break;
            case "2" : newType = "1"; break;
            case "3" : newType = "3"; break;
            case "4" : newType = "5"; break;
            case "5" : newType = "2"; break;
        }
        return newType;
    }

}
